
package com.util
{
	import flash.display.Sprite;
	
	import flashx.textLayout.container.DisplayObjectContainerController;
	import flashx.textLayout.elements.TextFlow;
	//import flashx.textLayout.formats.TextLayoutFormat;
	
	public class TextLayout
	{
		public var srcObject:Sprite;
		public var srcTextFlow:TextFlow;
		public var fheight:Number;
		public var fwidth:Number;
		public var fcolor:uint;
		public var fsize:Number;
		public var ftext:String;
		public var ffont:String;
		public var fleading:Number;
		public var fletterSpacing:Number;
		public var fthickness:Number;
		public var fhtml:Boolean;
		public var funderline:Boolean;
		public var fbold:Boolean;
		public var falign:String;
		
		/**
		 * constructor for Textlayout, set some default value for textlayout
		 *  */
		public function TextLayout()
		{
			srcObject =new Sprite();
			srcTextFlow = new TextFlow();
			fheight = 200;
			fwidth = 200;
			fcolor = 0x000000;
			fsize =12;
			ftext = "";
			ffont ="_arial";
			fleading = 0;
			fletterSpacing =0;
			fthickness = 0;
			fhtml = true;
			funderline = false;
			fbold = false;
			falign ="left";
			srcTextFlow=TextLayoutFormatter.format(srcObject,fwidth,fheight,fcolor,fsize,ftext,ffont,fleading,fletterSpacing
			,fthickness,fhtml,funderline,fbold,falign);			
		}
		/**
		 * Updata the text to display, 
		 * @param tt is a string which to set into to display
		 * @return a sprite which put into the stage
		 *  */
		public function updateText(tt:String):Sprite{						
			srcTextFlow.flowComposer.addController(new DisplayObjectContainerController(srcObject,fwidth,fheight));
			srcTextFlow.flowComposer.updateAllContainers();			
			return srcObject;
		}
		
		/**
		 * get the sprite  
		 * @return a sprite which put into the stage
		 *  */
		public function getSprite():Sprite{
			return srcObject;
		}
	}

}
